﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="NewTopic.aspx.cs" Inherits="Page_Community_NewTopic" %>




<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta name="format-detection" content="telephone=no" />
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
    <title>咨询</title>
    <meta name="apple-touch-fullscreen" content="yes" />
    <meta content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=0" name="viewport" />
    <meta content="yes" name="apple-mobile-web-app-capable" />
    <meta content="black" name="apple-mobile-web-app-status-bar-style" />
    <script src="../../Scripts/viewport.js"></script>
    <link href="../../CSS/base-640.css" rel="stylesheet" />
    <link href="../../CSS/say-something.css" rel="stylesheet" />
    <script src="../../Scripts/jquery-1.8.0.min.js"></script>
    <script src="../../Scripts/all.fineuploader-3.9.0-3.min.js"></script>



    <style>
        .saveTopic {
            color: #fff;
            line-height: 90px;
            float: right;
            font-size: 30px;
            padding-right: 20px;
            background-color: #d8261c;
        }
    </style>

</head>
<body>
    <div class="top">
        <a href="javascript:history.go(-1);"><span>取消</span></a>
        <span>咨询</span>
        <button class="saveTopic">发表</button>
    </div>
    <div class="hand">
        <textarea class="TopicContent" placeholder="写点什么吧..."></textarea>
        <div class="pic-list clearfix">
            <ul class="list">
            </ul>
            <div class="jion">
                <img src="http://cdn.xsmore.com/Images/bcy/t-jia.png" />
            </div>

            <div class="j_ion">
                添加照片
            </div>
            <input type="hidden" name="PicUrl" class="pic" />
        </div>
        <div class="pro-info clearfix" style="display: none">
            <ul></ul>
        </div>

    </div>

    <div class="layout" style="display: none"></div>

</body>

<script type="text/javascript">
    var uploadedCautionImg = false;//判断技术服务费截图是否上传完毕
    var chooseCautionImg = false;//判断是否选择了技术服务费截图
    var picUrl = "";

    $('.jion').fineUploader({
        text: { uploadButton: '' },
        request: {
            endpoint: '/Handler/UploadHandler.ashx?action=UploadTopicImage&type=TopicImage'
        },
        validation: {
            allowedExtensions: ['jpeg', 'jpg', 'gif', 'png'],
            //itemLimit: 3,
            sizeLimit: 20480000 // 20000 kB = 20000 * 1024 bytes

        },
        messages: {
            tooManyItemsError: "超出上传限制，最多可传3张图片",
            typeError: "超出上传格式限制：'jpeg', 'jpg', 'gif', 'png'",
            sizeError: "超出上传大小限制:最大可传20M图片",
            onLeave: "图片上传中"
        },
        template:
            '<div class="qq-uploader span12">' +
                '<pre class="qq-upload-drop-area span12"><span>{dragZoneText}</span></pre>' +
                '<div class="qq-upload-button btn btn-success" id="btnIDCardImg" style="width:140px; height: 200px;border-radius:4px;"><img src="../../Images/t-jia.png" /></div>' +
                '<span class="qq-drop-processing" style="display:none"><span>{dropProcessingText}</span>' +
                '<span class="qq-drop-processing-spinner"></span></span>' +
                '<ul class="qq-upload-list" style="margin-top: 10px; text-align: center;display:none;"></ul>' +
                '</div>',
        multiple: false,
        //autoUpload: false,
        debug: false
    }).on({
        "submit": function (event, id, fileName) {
            picUrl = "";
            var img = $(".pic").val().split(',');
            if (img.length > 0) {
                $(".saveTopic").attr("disabled", false);
                $(".saveTopic").css("color", "#fff");
            }
        },
        "complete": function (event, id, fileName, json) {
            var parent = $(this).data("id");
            if (json.success) {
                var html = "";
                picUrl += json.msg + ',';
                html = '<li><img class="imgurl" src="' + json.msg + '"><span class="delete">X</span></li>';
                $(".list", this.parentNode.parentNode).prepend(html);
            }
            $(".pic").val($(".pic").val() + picUrl);
        }
    });





    //删除图片
    $(".pic-list").on("click", ".delete", function () {
        var parent = this.parentNode;
        $(parent).remove();

        if (!$(".pic-list li").length) {
            $(".j_ion").show();
        }
        var imgUrl = $(".imgurl", this.parentNode).attr("src").replace("http://img.bcyoo.com", ""); //src
        var oldimglist = $(".pic").val().replace(imgUrl, "").replace(",,", ","); //input
        $(" .pic").val(oldimglist);

        var img = $(".pic").val().split(',');
        if (img.length > 0) {
            $(".saveTopic").attr("disabled", "disabled");
            $(".saveTopic").css("color", "grey");
        }
    });



    (function () {
        $(".saveTopic").attr("disabled", "disabled");
        $(".saveTopic").css("color", "grey");

    })();



    $(".TopicContent").on("keyup", function () {
        var topicContent = $(".TopicContent").val();
        if (topicContent.length > 0) {
            $(".saveTopic").attr("disabled", false);
            $(".saveTopic").css("color", "#fff");
        } else {
            $(".saveTopic").attr("disabled", "disabled");
            $(".saveTopic").css("color", "grey");
        }
    });


    $(".saveTopic").on("click", function () {
        var topicContent = $(".TopicContent").val();
        var pic = $(".pic").val();
        $.post("/Handler/CommunityHandler.ashx?Action=SaveTopic", { TopicContent: topicContent, Pic: pic, openid: '<%=openid%>', CardId: '<%=CardId%>' }, function (data) {
                var evalResult = eval("(" + data + ")");
                if (evalResult.status == 1) {
                    //layer.msg(evalResult.info, {
                    //    time: 1000 //2秒关闭（如果不配置，默认是3秒）
                    //}, function () {
                    //    window.location.href = "QuestionList.aspx?";
                    //});
                    alert(evalResult.info);
                    window.location.href = "QuestionList.aspx?openid='<%=openid%>'";

                }
                else {
                    alert(evalResult.info);
                    //layer.msg(evalResult.info, {
                    //    time: 1000 //2秒关闭（如果不配置，默认是3秒）
                    //});
                }
            });
        });




</script>

</html>
